import socketio, re
from urls import urls


class WSGIAPP(socketio.WSGIApp):

    def __call__(self, environ, start_response):
        '''
        重写 __call__ 方法  加入自定义url  更多python中的wsgi应用 请自行搜索博客 或者自行查看源码
        :param environ: 请求信息
        :param start_response: 确定返回信息
        :return:
        '''
        path = environ['PATH_INFO']
        for url in urls.urls.keys():
            match = re.fullmatch(url, path)
            if match:
                return urls.urls[url](environ, start_response)
        return super(WSGIAPP, self).__call__(environ, start_response)
